﻿@using IdentityServer4.Extensions
@using Microsoft.AspNetCore.Identity
@using Microsoft.AspNetCore.Mvc.Localization
@using SkorubaIdentityServer4Admin.Admin.EntityFramework.Shared.Entities.Identity
@using SkorubaIdentityServer4Admin.STS.Identity.Configuration.Interfaces
@inject IRootConfiguration RootConfiguration
@inject IViewLocalizer Localizer
@{
    string name = null;
    if (!true.Equals(ViewData["signed-out"]))
    {
        name = Context.User?.GetDisplayName();
    }
}

@inject SignInManager<UserIdentity> SignInManager
@{
    var hasExternalLogins = (await SignInManager.GetExternalAuthenticationSchemesAsync()).Any();
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@RootConfiguration.AdminConfiguration.PageTitle</title>
    <link rel="icon" type="image/x-icon" href="@UrlHelper.Content(RootConfiguration.AdminConfiguration.FaviconUri)" />
    <link rel="shortcut icon" type="image/x-icon" href="@UrlHelper.Content(@RootConfiguration.AdminConfiguration.FaviconUri)" />

    <environment include="Development">
        <link href="~/dist/css/bundle.min.css" asp-append-version="true" rel="stylesheet" />
        @await Html.PartialAsync("Common/ThemeResources")
        <link href="~/dist/css/web.css" asp-append-version="true" rel="stylesheet" />
    </environment>
    <environment exclude="Development">
        <link href="~/dist/css/bundle.min.css" asp-append-version="true" rel="stylesheet" />
        @await Html.PartialAsync("Common/ThemeResources")
        <link href="~/dist/css/web.min.css" asp-append-version="true" rel="stylesheet" />
    </environment>

    @if (!string.IsNullOrEmpty(RootConfiguration.AdminConfiguration.CustomThemeCss))
    {
        <link href="@UrlHelper.Content(RootConfiguration.AdminConfiguration.CustomThemeCss)" asp-append-version="true" rel="stylesheet" />
    }

    @await RenderSectionAsync("styles", required: false)
</head>
<body>

    <div class="menu d-flex flex-column flex-md-row align-items-center p-3 px-md-4 mb-3 border-bottom box-shadow">
        <!--Site name -->
        <h3 class="menu-logo my-0 mr-md-auto font-weight-normal"><a class="logo" asp-area="" asp-controller="Home" asp-action="Index">@RootConfiguration.AdminConfiguration.PageTitle</a></h3>
        <!--Menu item -->
        @if (User.Identity.IsAuthenticated && !string.IsNullOrEmpty(name))
        {
            <!--Menu item -->
            <vc:identity-server-admin-link></vc:identity-server-admin-link>

            <!--Menu item -->
            <div class="menu-item my-2 my-md-0 mr-md-3 dropdown">
                <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
                    @Localizer["Settings"] - @name
                </button>
                <div class="dropdown-menu">
                    <a class="dropdown-item" asp-controller="Manage" asp-action="Index">@Localizer["ManageProfile"]</a>
                    <a class="dropdown-item" asp-controller="Manage" asp-action="PersonalData">@Localizer["ManagePersonalData"]</a>
                    @if (hasExternalLogins)
                    {
                        <a class="dropdown-item" asp-controller="Manage" asp-action="ExternalLogins">@Localizer["ExternalLogins"]</a>
                    }
                    <a class="dropdown-item" asp-controller="Manage" asp-action="TwoFactorAuthentication">@Localizer["2FA"]</a>
                    <a class="dropdown-item" asp-controller="Manage" asp-action="ChangePassword">@Localizer["ChangePassword"]</a>
                    <a class="dropdown-item" asp-controller="Grants" asp-action="Index">@Localizer["Grants"]</a>
                </div>
            </div>

            <a class="menu-item my-2 btn btn-outline-primary" asp-action="Logout" asp-controller="Account">@Localizer["Signout"]</a>
        }

        <!--Menu button - show in < MD -->
        <a class="my-2 btn btn-outline-primary menu-button" href="#">
            <span class="oi oi-menu" title="menu" aria-hidden="true"></span> @Localizer["Menu"]
        </a>
    </div>

    <div class="container">
        @RenderBody()

        <footer class="pt-4 my-md-5 pt-md-5 border-top">
            <div class="row">
                <div class="col-6 col-md">
                    @RootConfiguration.AdminConfiguration.PageTitle
                    <small class="d-block mb-3 text-muted">@Localizer["FooterCopyright"] @DateTime.Now.Year - @await Html.PartialAsync("Common/ApplicationVersion")</small>
                </div>
                <div class="col-md-3 text-right">
                    @await Html.PartialAsync("Common/SelectTheme")
                </div>
                <div class="col-md-3 text-right">
                    @await Html.PartialAsync("Common/SelectLanguage")
                </div>
            </div>
        </footer>
    </div>

    <environment include="Development">
        <script src="~/dist/js/bundle.min.js" asp-append-version="true"></script>
    </environment>
    <environment exclude="Development">
        <script src="~/dist/js/bundle.min.js" asp-append-version="true"></script>
    </environment>

    @await RenderSectionAsync("scripts", required: false)
</body>
</html>








